package com.atguigu.gulimall.product.thread;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;

public class ThreadTest {
    private static ExecutorService executorService = Executors.newFixedThreadPool(10);

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        System.out.println("main开始");
      /*  MyThread thread = new MyThread();
        thread.start();*/
//        Thread thread = new Thread(new MyRun());
//        thread.start();
//        FutureTask<Integer> futureTask = new FutureTask<>(new MyCallable());
//        Thread thread = new Thread(futureTask);
//        Integer integer = futureTask.get();
//        thread.start();
//        List list = new ArrayList();
//        list.add(1);
        executorService.execute(new MyRun());
        System.out.println("main结束");
    }
    private static class MyThread extends Thread{
        @Override
        public void run() {
            System.out.println("当前线程--->"+Thread.currentThread().getId());
            int i = 10/5;
            System.out.println("运行结果"+i);
        }
    }
    private static class MyRun implements Runnable{

        @Override
        public void run() {
            System.out.println("当前线程--->"+Thread.currentThread().getId());
            int i = 10/5;
            System.out.println("运行结果"+i);
        }
    }
    private static class MyCallable implements Callable<Integer>{

        @Override
        public Integer call() throws Exception {
            System.out.println("当前线程--->"+Thread.currentThread().getId());
            int i = 10/5;
            System.out.println("运行结果"+i);
            return i;
        }
    }

}
